package fieldmaps.representation;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LinearRing;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Polygon;

public class GeometryMapRepresentation {

	List<Polygon> cells = new ArrayList<Polygon>();
	Iterator<Polygon> iterator;
	
	public void addCell(LinearRing shell, int value) {
		Polygon shape = new Polygon(shell, null, new GeometryFactory());
		shape.setUserData(value);
		cells.add(shape);
	}
	
	public Polygon getCell(Point point) {
		for (Polygon currentCell : cells) {
			if (currentCell.contains(point)) {
				return currentCell;
			}
		}
		return null;
	}

}
